package com.example.shoppingmall.service;

import com.example.shoppingmall.dao.PromotionMapper;
import com.example.shoppingmall.pojo.Commodity;
import com.example.shoppingmall.pojo.Promotion;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class PromotionService {
    @Resource
    PromotionMapper promotionMapper;

     //查询秒杀信息
    public List<Promotion> getAll(String name,int status,String startTime,String endTime,int dang, int size){

        int num=(dang-1)*size;

      return  promotionMapper.getAll(name,status,startTime,endTime,num,size);
    }
        //分页总条数
        public int count(String name,int status,String startTime,String endTime){

        return promotionMapper.count(name,status,startTime,endTime);
    }
    //查询所有商品
    public List<Commodity> getAllComm(){

            return promotionMapper.getAllComm();
    }
    //删除秒杀
    public int del( int id){

        return promotionMapper.del(id);
    }

    //新增秒杀
    public int add(Promotion promotion){

        return promotionMapper.add(promotion);
    }

    //根据id查询秒杀信息
    public  Promotion getById(int id){

        return promotionMapper.getById(id);
    }
    //修改秒杀信息
    public  int update(Promotion promotion){

        return promotionMapper.update(promotion);
    }
}
